//
//  GZtabbar.swift
//  iosswift
//
//  Created by apple on 15/11/23.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit

class GZtabbar: UITabBar {
    
    
   
    override func layoutSubviews() {
        super.layoutSubviews()
        let width=bounds.width*0.2
        var index=0
        let frames = CGRect(x: 0, y: 0, width: width, height: bounds.height)
        for  button in subviews
        {
            if button is UIControl && !(button is UIButton)
            {
                button.frame=CGRectOffset(frames, width*CGFloat(index), 0)
                index += index == 1 ? 2 : 1
            }
        }
        button.frame=CGRectOffset(frames, width*2, 0)
        
    }
     lazy var button:UIButton = {
        let button = UIButton()
        button.setBackgroundImage(UIImage(named: "tabbar_compose_button"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "tabbar_compose_button_highlighted"), forState: UIControlState.Highlighted)
        
        button.setImage(UIImage(named: "tabbar_compose_icon_add"), forState: UIControlState.Normal)
        button.setImage(UIImage(named: "tabbar_compose_icon_add_highlighted"), forState: UIControlState.Highlighted)
        
        self.addSubview(button)
        return button
    }()
}
